import Taro from '@tarojs/taro'
import {View} from '@tarojs/components'
import { useEffect,useState } from 'react'
import { PostCard,CompanyCard,NoFavorite } from '../../../components'
import { getFavorite } from '../../../api/mode'
import './index.scss'

export default function MyFavorite(){
  const isDetail=true
  const [positionList,setPositionList]=useState([])
  const [companyList,setCompanyList]=useState([])
  useEffect(()=>{
    getFavorite(Taro.getStorageSync(`openid`)).then(
      res=>{
        console.log(res.data.data);
        setPositionList(res.data.data.positionList)
        setCompanyList(res.data.data.companyList)
      }
    )
  },[])

  return(
    <View className='myFavorite'>
      <View className='Hint'>
        我收藏的职位:
      </View>
          {positionList?positionList.map((Info,index)=>(<PostCard key={index} Info={Info} canJump isDetail={isDetail} isCollected={Info.collected}></PostCard>)):<NoFavorite />}
 
          <View className='Hint'>
        我收藏的企业:
            </View>
          {companyList?companyList.map((Info,index)=>(<CompanyCard key={index} Info={Info} isCollected={Info.collected} isSpecial={0}></CompanyCard>)):<NoFavorite />}
    </View>
  )
}